//
//  ViewController.swift
//  customKeyboard
//
//  Created by changhongliang on 2017/8/12.
//  Copyright © 2017年 richinfo. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    
    @IBOutlet weak var textView: KeyboardTextView!
    
    /*
     传入的字典如果包含NSAttachment证明是表情,并且字典中传入的NSAttachment和当初插入表情时创建的NSAttachment是以同一个NSAttachment
     */
    
    @IBAction func buttonClick(_ sender: Any) {
        let str = self.textView.emoticonString()
       
        print(str)
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        addChildViewController(keyboardEmotionVC)
        textView.inputView = keyboardEmotionVC.view
        textView.spellCheckingType = .no
        textView.autocorrectionType = .no
    
        
    }
    
 
    lazy var keyboardEmotionVC: KeyboardEmoticonViewController = KeyboardEmoticonViewController {[unowned self] (emoticon) in
         self.textView.insertEmoticon(emoticon: emoticon)
    }
}






